Unix Source Compile Apache with PHP Support
Installing Apache with PHP Support on UNIX This article is optional for a working pvpgn server, but it's a must for every pvpgn admin that wants to run a website for the server and for its players. Software and files you need: *Apache server *PHP module The easy part - getting the sources First of all we need to get the apache httpd webserver sources and then the php sources. Let's do the trick: *you can get apache httpd webserver from: http://httpd.apache.org/download.cgi *you can get the php sources from: http://www.php.net/downloads.php#v5 After getting the sources you can upload them to your host(if you downloaded them on your working station with WinSCP) or you can move them (if you downloaded them on server) to /usr/src/ directory. Once the file where moved you must unpack them (using tar) like: root@mybox#tar xf httpd-2.2.8.tar.gz root@mybox#tar xf php-5.2.6.tar.gz After unpacking them you'll have 2 new folder with the following names: /usr/src/httpd-2.2.8/ /usr/src/php-5.2.6/ The not so easy part - compiling / installing After we have done all the above things is time to start compiling apache httpd. We must enter the httpd source directory: root@mybox#cd /usr/src/httpd-2.2.8/ Now we can issue the configure command: root@mybox#./configure --prefix=/opt/apache228 --enable-mods-shared=most --enable-so --enable-cache --enable-file-cache --enable-disk-cache --enable-mem-cache If everything will be fine you'll be able to issue the make and make install commands: root@mybox#make root@mybox#make install Now you should be able to start your webserver by issuing the commands: root@mybox#apachectl start - if you compiled without the --prefix parameter or root@mybox#/opt/apache228/bin/apachectl start - if you used the --prefix=/opt/apache228/ parameter If everything was done correctly, after the issuing one of the above commands your cursor should be similar: root@mybox# If not you should get some errors or warnings (warnings are not so harmfully but still not ok). You can also check the logs from apache by opening the error_log file from the logs directory created by apache httpd installation (in our example this would be /opt/apache228/logs/). You can check to see if apache httpd is running in background using the following command: root@mybox#ps ax | grep httpd If the httpd server is running you should get similar output: root@mybox#ps ax | grep httpd 26073 ? Ss 0:00 /opt/apache228/bin/httpd -k start 16670 ? S 0:01 /opt/apache228/bin/httpd -k start 16837 ? S 0:00 /opt/apache228/bin/httpd -k start 16838 ? S 0:01 /opt/apache228/bin/httpd -k start 16839 ? S 0:00 /opt/apache228/bin/httpd -k start 16841 ? S 0:00 /opt/apache228/bin/httpd -k start 16842 ? S 0:00 /opt/apache228/bin/httpd -k start 16843 ? S 0:00 /opt/apache228/bin/httpd -k start 16846 ? S 0:00 /opt/apache228/bin/httpd -k start 16848 ? S 0:01 /opt/apache228/bin/httpd -k start 16998 ? S 0:00 /opt/apache228/bin/httpd -k start 30228 pts/1 R+ 0:00 grep httpd If all above are ok, you can test it by entering in your browser address bar the ip / dns of your server: (we'll assume that your server has a public ip address and will assume that the address is 10.10.10.250 - don't start yelling, i know that this isn't possible for real but we assume) http://10.10.10.250/ or http://your.dns.record/ Now we can shutdown the httpd server for the moment by issuing: root@mybox#apachectl stop - if you compiled without the --prefix parameter or root@mybox#/opt/apache228/bin/apachectl stop - if you used the --prefix=/opt/apache228/ parameter Now it's time for php! We must exit the apache httpd source directory: root@mybox#cd ../ and enter the php source directory: root@mybox#cd php-5.2.6/ Now we must start the compiling thing: root@mybox#./configure --prefix=/opt/php526/ \ >--with-apxs=/path/to/apache/bin/folder/apxs \ >--with-mysql=/path/to/mysql \ >--enable-fastcgi \ >--enable-calendar \ >--enable-bcmath \ >--enable-exif \ >--enable-mbstring \ >--with-gettext \ >--with-gd \ >--with-pear If everything went well you can start compiling and installing php: root@mybox#make root@mybox#make install If everything went well the next thing is copying a php.ini file from the source directory to the /lib/ directory or to the /lib/ directory inside the directory entered on parameter --prefix: root@mybox#mv php.ini-recommended php.ini - renaming the included php.ini to the usable name root@mybox#cp php.ini /lib/ - copy to the lib directory if install path is default or root@mybox#cp php.ini /opt/php526/lib/php.ini - copy to the lib directory from the install path configured with the --prefix parameter At this time there is no need to configure anything more in php.ini, but in time, if you want to take full advantage of you machine and your software then you should take a look inside that file. The install script will use apxs binary to make the necessary changes in the httpd config file to include the php binary module. The last thing you have to do is to open the httpd config file ( in our example it is located in /opt/apache228/conf/httpd.conf ) and add the following lines: look for: DirectoryIndex index.html and change to: DirectoryIndex index.html index.php look for: AddType application/x-compress .Z AddType application/x-gzip .gz .tgz and change to: AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php and after that save and close the httpd.conf file. Now you can start again your httpd server and go to the htdocs directory (in our case it is /opt/apache228/htdocs) and create an empty file (which in this tutorial we'll call it phpinfo.php) in which you must write: and save the file. If the installation was a success you will be able to tell by pointing your browser to: http://10.10.10.250/phpinfo.php or http://your.dns.record/phpinfo.php If you had done everything right you should get similar output: If you see this you have successfully compiled and installed apache httpd webserver with php module support and mysql database integration. Category:Admin Tools